import store from '@/core/store.js'
//发起请求拦截
export const requestBefore = (options) => {
	
	options.baseUrl = options.baseUrl || 'http://122.237.101.223:1001/api/admin/';
    options.header = {
        'Authori-zation': store.state.account.token,
        'content-type': 'application/json',
		...options.header
    }
    return options
}
//返回成功拦截
export const responseSuccess = (res, resolve, reject) => {
    if (res.statusCode == 200) {
		if (res.data.code == 200) {
            resolve(res.data.data)
        }
        else {
            reject(res.data.message)
        }
    }
	else{
		reject(`请求出错：${res.errMsg},错误代码：${res.errno}`)
	}
	
}

//返回失败拦截
export const responseFail = (res,reject) => {
	reject('请求失败')
}